package com.visitor;

import com.visitor.hidein.Element;
import com.visitor.hidein.impl.ConcreteElementA;
import com.visitor.hidein.impl.ConcreteElementB;
import com.visitor.showout.Visitor;
import com.visitor.showout.impl.ConcreteVisitorA;
import com.visitor.showout.impl.ConcreteVisitorB;

public class Test {
    public static void main(String[] args) {
        ObjectAccept oa = new ObjectAccept();
        // 添加两个可访问的功能（假设有>=2个功能类）
        Element elementA = new ConcreteElementA();
        oa.add(elementA);
        oa.add(new ConcreteElementB());

        // 访问者A去访问这两个功能
        Visitor a = new ConcreteVisitorA();
        oa.accept(a);
        System.out.println("-----------------------");
        // 访问者B只能访问一个功能
        Visitor b = new ConcreteVisitorB();
        oa.remove(elementA);
        oa.accept(b);
    }
}
